package com.luming.ethtran.controller;

import com.luming.ethtran.domain.DTO.PasswordUpdateRequest;
import com.luming.ethtran.domain.Result;
import com.luming.ethtran.domain.SysUser;
import com.luming.ethtran.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author Luming
 * @Date 2025/3/24 18:22
 * @Description:
 */
@RestController
@RequestMapping("/sys")
@CrossOrigin(origins = "http://localhost:5173") // 允许跨域的前端地址
public class SysUserController {
    
    @Autowired
    private ISysUserService iSysUserService;
    
    // 修改个人信息
    @PutMapping("/updateInfo")
    public Result updateInfo(@RequestBody SysUser sysUser) {
        return iSysUserService.updateInfo(sysUser);
    }
    
    // 修改密码
    @PutMapping("/updatePassword")
    public Result updatePassword(@RequestBody PasswordUpdateRequest request) {
        return iSysUserService.updatePassword(request.getUserId(), request.getOldPassword(), request.getNewPassword());
    }
}
